#include <hxcpp.h>

#ifndef INCLUDED_JOutput
#include <JOutput.h>
#endif
#ifndef INCLUDED_JPrintStream
#include <JPrintStream.h>
#endif
#ifndef INCLUDED_Std
#include <Std.h>
#endif
#ifndef INCLUDED_StringBuf
#include <StringBuf.h>
#endif
#ifndef INCLUDED_Sys
#include <Sys.h>
#endif
#ifndef INCLUDED_cpp_CppInt32__
#include <cpp/CppInt32__.h>
#endif
#ifndef INCLUDED_haxe_io_Output
#include <haxe/io/Output.h>
#endif

Void JOutput_obj::__construct()
{
{
	HX_SOURCE_POS("Source/JSystem.hx",36)
	super::__construct();
	HX_SOURCE_POS("Source/JSystem.hx",37)
	this->out = null();
	HX_SOURCE_POS("Source/JSystem.hx",38)
	this->aout = ::StringBuf_obj::__new();
}
;
	return null();
}

JOutput_obj::~JOutput_obj() { }

Dynamic JOutput_obj::__CreateEmpty() { return  new JOutput_obj; }
hx::ObjectPtr< JOutput_obj > JOutput_obj::__new()
{  hx::ObjectPtr< JOutput_obj > result = new JOutput_obj();
	result->__construct();
	return result;}

Dynamic JOutput_obj::__Create(hx::DynamicArray inArgs)
{  hx::ObjectPtr< JOutput_obj > result = new JOutput_obj();
	result->__construct();
	return result;}

Void JOutput_obj::append( int c){
{
		HX_SOURCE_PUSH("JOutput_obj::append")
		HX_SOURCE_POS("Source/JSystem.hx",41)
		::StringBuf _this = this->aout;
		HX_SOURCE_POS("Source/JSystem.hx",41)
		hx::IndexRef((_this->b).mPtr,_this->b->__Field(HX_CSTRING("length"),true)) = ::String::fromCharCode(c);
	}
return null();
}


Void JOutput_obj::print( Dynamic d){
{
		HX_SOURCE_PUSH("JOutput_obj::print")
		HX_SOURCE_POS("Source/JSystem.hx",44)
		::StringBuf _this = this->aout;
		HX_SOURCE_POS("Source/JSystem.hx",44)
		hx::IndexRef((_this->b).mPtr,_this->b->__Field(HX_CSTRING("length"),true)) = ::Std_obj::string(d);
	}
return null();
}


Void JOutput_obj::println( Dynamic d){
{
		HX_SOURCE_PUSH("JOutput_obj::println")
		HX_SOURCE_POS("Source/JSystem.hx",47)
		this->print(d);
		HX_SOURCE_POS("Source/JSystem.hx",48)
		this->print(HX_CSTRING("\n"));
		HX_SOURCE_POS("Source/JSystem.hx",49)
		this->flush();
	}
return null();
}


Void JOutput_obj::write( ::cpp::CppInt32__ b){
{
		HX_SOURCE_PUSH("JOutput_obj::write")
		HX_SOURCE_POS("Source/JSystem.hx",52)
		::StringBuf _this = this->aout;
		HX_SOURCE_POS("Source/JSystem.hx",52)
		hx::IndexRef((_this->b).mPtr,_this->b->__Field(HX_CSTRING("length"),true)) = ::String::fromCharCode(::cpp::CppInt32___obj::toInt(b));
	}
return null();
}


Void JOutput_obj::flush( ){
{
		HX_SOURCE_PUSH("JOutput_obj::flush")
		HX_SOURCE_POS("Source/JSystem.hx",55)
		Array< ::String > lines = this->aout->b->__Field(HX_CSTRING("join"),true)(HX_CSTRING(""))->__Field(HX_CSTRING("split"),true)(HX_CSTRING("\n"));
		HX_SOURCE_POS("Source/JSystem.hx",56)
		this->aout = ::StringBuf_obj::__new();
		HX_SOURCE_POS("Source/JSystem.hx",57)
		{
			HX_SOURCE_POS("Source/JSystem.hx",57)
			int _g = (int)0;
			HX_SOURCE_POS("Source/JSystem.hx",57)
			while(((_g < lines->length))){
				HX_SOURCE_POS("Source/JSystem.hx",57)
				::String l = lines->__get(_g);
				HX_SOURCE_POS("Source/JSystem.hx",57)
				++(_g);
				HX_SOURCE_POS("Source/JSystem.hx",59)
				::Sys_obj::println(l);
			}
		}
	}
return null();
}


Void JOutput_obj::close( ){
{
		HX_SOURCE_PUSH("JOutput_obj::close")
		HX_SOURCE_POS("Source/JSystem.hx",72)
		this->flush();
	}
return null();
}



JOutput_obj::JOutput_obj()
{
}

void JOutput_obj::__Mark(HX_MARK_PARAMS)
{
	HX_MARK_BEGIN_CLASS(JOutput);
	HX_MARK_MEMBER_NAME(aout,"aout");
	super::__Mark(HX_MARK_ARG);
	HX_MARK_END_CLASS();
}

void JOutput_obj::__Visit(HX_VISIT_PARAMS)
{
	HX_VISIT_MEMBER_NAME(aout,"aout");
	super::__Visit(HX_VISIT_ARG);
}

Dynamic JOutput_obj::__Field(const ::String &inName,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"aout") ) { return aout; }
		break;
	case 5:
		if (HX_FIELD_EQ(inName,"print") ) { return print_dyn(); }
		if (HX_FIELD_EQ(inName,"write") ) { return write_dyn(); }
		if (HX_FIELD_EQ(inName,"flush") ) { return flush_dyn(); }
		if (HX_FIELD_EQ(inName,"close") ) { return close_dyn(); }
		break;
	case 6:
		if (HX_FIELD_EQ(inName,"append") ) { return append_dyn(); }
		break;
	case 7:
		if (HX_FIELD_EQ(inName,"println") ) { return println_dyn(); }
	}
	return super::__Field(inName,inCallProp);
}

Dynamic JOutput_obj::__SetField(const ::String &inName,const Dynamic &inValue,bool inCallProp)
{
	switch(inName.length) {
	case 4:
		if (HX_FIELD_EQ(inName,"aout") ) { aout=inValue.Cast< ::StringBuf >(); return inValue; }
	}
	return super::__SetField(inName,inValue,inCallProp);
}

void JOutput_obj::__GetFields(Array< ::String> &outFields)
{
	outFields->push(HX_CSTRING("aout"));
	super::__GetFields(outFields);
};

static ::String sStaticFields[] = {
	String(null()) };

static ::String sMemberFields[] = {
	HX_CSTRING("aout"),
	HX_CSTRING("append"),
	HX_CSTRING("print"),
	HX_CSTRING("println"),
	HX_CSTRING("write"),
	HX_CSTRING("flush"),
	HX_CSTRING("close"),
	String(null()) };

static void sMarkStatics(HX_MARK_PARAMS) {
};

static void sVisitStatics(HX_VISIT_PARAMS) {
};

Class JOutput_obj::__mClass;

void JOutput_obj::__register()
{
	Static(__mClass) = hx::RegisterClass(HX_CSTRING("JOutput"), hx::TCanCast< JOutput_obj> ,sStaticFields,sMemberFields,
	&__CreateEmpty, &__Create,
	&super::__SGetClass(), 0, sMarkStatics, sVisitStatics);
}

void JOutput_obj::__boot()
{
}

